const { link } = require('fs');
const {User} = require('../../model/user');

module.exports = async (req,res) => {

    //标识 表示当 前访问的页面
    req.app.locals.currentLink = 'user';

    const {message,id} = req.query;

    if(id) {
        const user = await User.findOne({_id: id})

        res.render('admin/user-edit',{
        message: message,
        user: user,
        link: '/admin/user-modify?id=' + id,
        button: '修改'
    });
    }else {
        res.render('admin/user-edit',{
            message: message,
            link: '/admin/user-edit',
            button: '添加'
        });
    }
}